package com.itheima.consumer.controller;

import com.itheima.consumer.feign.UserClient;
import com.itheima.consumer.loadbanlace.MyLoadBanlanceRule;
import com.itheima.consumer.pojo.User;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @作者 itcast
 * @创建日期 2020/11/8 9:55
 **/
@RestController
@RequestMapping("consumer")
public class ConsumerController {
    @Autowired
    UserClient userClient;
    @GetMapping("{id}")
    public String findById(@PathVariable("id")Long id, HttpServletRequest request){
        User user = new User();
        user.setName("xiaoming");
        userClient.add(user);
        // 获取请求头
        String title = request.getHeader("title");
        System.out.println("请求头信息:" + title);

        return userClient.findById(id);
    }
}
